package com.atguigu.srb.core.controller.api;


import com.atguigu.srb.base.result.ResponseVo;
import com.atguigu.srb.core.pojo.entity.IntegralGrade;
import com.atguigu.srb.core.service.IntegralGradeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 积分等级表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-03-25
 */
@RestController
@RequestMapping("/api/core/integralGrade")
@Api(tags = "积分等级用户模块")
public class ApiIntegralGradeController {
    @Resource
    IntegralGradeService integralGradeService;

    @ApiOperation("查询会员的借款额度")
    @GetMapping("borrowAmount")
    public ResponseVo borrowAmount(@RequestHeader(value = "token",required = false)
                                           String token){
        BigDecimal amount = integralGradeService.getBorrowAmountByUserId(token);
        return ResponseVo.ok().data("amount",amount);
    }

    @ApiOperation("根据id查询积分等级")
    @GetMapping("{id}")  // get+/integralGrade/id
    //@ApiParam("积分等级id")
    public IntegralGrade getById( @PathVariable("id")Long id){

        return integralGradeService.getById(id);
    }
}

